Skip to content

Add longest-line sizing for wrapped Text - #58351

Open
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D118718410
Open

Add longest-line sizing for wrapped Text#58351
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D118718410

Conversation

@Abbondanzo

Copy link
Copy Markdown
Contributor

Summary:
Add textWidthMode="longest-line" to size wrapped Text to its widest rendered line on Android and iOS. This keeps content-proportional spacing in horizontal layouts without an onTextLayout round trip; the default measurement behavior is unchanged.

Changelog:
[General][Added] - Add textWidthMode="longest-line" for sizing wrapped Text to its widest rendered line.

Differential Revision: D118718410

Summary:
Add `textWidthMode="longest-line"` to size wrapped `Text` to its widest rendered line on Android and iOS. This keeps content-proportional spacing in horizontal layouts without an `onTextLayout` round trip; the default measurement behavior is unchanged.

Changelog:
[General][Added] - Add `textWidthMode="longest-line"` for sizing wrapped `Text` to its widest rendered line.

Differential Revision: D118718410
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 4, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Sep 4, 2026
@meta-codesync

meta-codesync Bot commented Sep 4, 2026

Copy link
Copy Markdown

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118718410.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@Abbondanzo

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

🤖 AI code review

Decision: Ready for human review (with comments)

Overall PR risk: Low. Change is additive and leaves the default measurement path unchanged. Blast radius is limited to Text that sets the new mode. Most plausible break is Paper Android keeps the old width after a prop change because the diff omits the new field.

🟡 Warning (1)

  • Android Paper diff drops new textWidthModepackages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h:49 (correctness) · id:ae5d4f4999c1
    Confidence: Medium — the new field reaches Fabric state but the Paper serializer lacks it.
    Impact if shipped: Medium — Paper Android keeps the old width after a prop change.
    Suggested remediation: Add a textWidthMode branch to HostPlatformParagraphProps::getDiffProps, using toString(paragraphAttributes.textWidthMode).

    Evidence and reasoning

    The PR adds textWidthMode to ParagraphAttributes. Fabric state uses toMapBuffer. That path includes the new key. Android Fabric and iOS Fabric read the new value. HostPlatformParagraphProps getDiffProps serializes ParagraphAttributes for Paper. It handles numberOfLines, ellipsizeMode, textBreakStrategy, adjustsFontSizeToFit, minimumFontSize, maximumFontSize, includeFontPadding, hyphenationFrequency, and textAlignVertical. It has no branch for textWidthMode. A Paper update therefore drops the prop. The view keeps the old width.


This review is advisory — it never blocks a merge and never auto-approves.

@Abbondanzo

Copy link
Copy Markdown
Contributor Author

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant